﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;
using System.Reflection;

namespace Common.Configs
{
    public static class Settings
    {
        #region Fields

        private static XmlDocument _configDocument;
        private static XmlNode _configurationNode;
        private static Assembly _assembly;
        private static Stream _stream;

        #endregion

        #region Properties

        public static int LengthMethod { get; set; }
        public static int LengthVariable { get; set; }

        #endregion

        #region Static Constructor

        static Settings()
        {
            _assembly = Assembly.GetExecutingAssembly();
            _stream = _assembly.GetManifestResourceStream("Common.Configs.Config.xml");
            
            //Carregar configurações
            _configDocument = new XmlDocument();
            _configDocument.Load(_stream);
            _configurationNode = _configDocument["Configuration"];

            //Carregar propriedades
            LengthMethod = Convert.ToInt32(_configurationNode["LengthMethodName"].InnerText);
            LengthVariable = Convert.ToInt32(_configurationNode["LengthVariableName"].InnerText);
        }

        #endregion
    }
}
